package org.easymodelers.gmf.creator.impl;

import java.io.IOException;

import org.easymodelers.gmf.utils.GmfModelsUtils;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.gmf.gmfgraph.Canvas;
import org.eclipse.gmf.tooldef.ToolRegistry;

public class AbstractPreModelsCreator {

	protected String getMetaModelPath(String gmfMapModelPath) {
		return gmfMapModelPath.replace(".gmfmap", ".ecore");
	}

	protected EPackage getMetaModelFromGmfMapModel(String gmfMapModelPath) throws IOException {
		String metaModelPath = getMetaModelPath(gmfMapModelPath);
		return GmfModelsUtils.getMetaModel(metaModelPath);
	}

	protected String getGmfGraphModelPath(String gmfMapModelPath) {
		return gmfMapModelPath.replace(".gmfmap", ".gmfgraph");
	}

	protected Canvas getGmfGraphModelFromGmfMapModel(String gmfMapModelPath) throws IOException {
		String gmfGraphPath = getGmfGraphModelPath(gmfMapModelPath);
		//gmfGraphPath = gmfGraphPath.substring(gmfGraphPath.lastIndexOf(File.separator)+1);
		return GmfModelsUtils.getGmfGraphModel(gmfGraphPath);
	}

	protected String getGmfToolModelPath(String gmfMapModelPath) {
		return gmfMapModelPath.replace(".gmfmap", ".gmftool");
	}

	protected ToolRegistry getGmfToolModelFromGmfMapModel(String gmfMapModelPath) throws IOException {
		String gmfToolPath = getGmfToolModelPath(gmfMapModelPath);
		return GmfModelsUtils.getGmfToolModel(gmfToolPath);
	}

}
